package com.freak.neteasecloudmusic.modules.find.recommend.songlist.all;

import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.freak.neteasecloudmusic.R;
import com.freak.neteasecloudmusic.modules.find.recommend.entity.SongListCategoryEntity;
import com.freak.neteasecloudmusic.modules.find.recommend.songlist.all.entity.MyMultiItemEntity;
import com.freak.neteasecloudmusic.modules.find.recommend.songlist.all.entity.SongTypeEntity;

import java.util.List;

public class AllClassifyAdapter extends BaseMultiItemQuickAdapter<MyMultiItemEntity, BaseViewHolder> {

    public final static int ITEM_NAME = 1;
    public final static int ITEM_TYPE = 0;
    public final static int ITEM_NAME_SIZE = 1;
    public final static int ITEM_TYPE_SIZE = 4;

    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public AllClassifyAdapter(List<MyMultiItemEntity> data) {
        super(data);
        addItemType(ITEM_NAME, R.layout.item_all_song_list);
        addItemType(ITEM_TYPE, R.layout.item_all_song_list_type);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MyMultiItemEntity item) {
        switch (helper.getItemViewType()) {
            case ITEM_NAME:
                SongListCategoryEntity.SubBean subBean = (SongListCategoryEntity.SubBean) item;
                helper.setText(R.id.textViewAllClassifyItemName, subBean.getName());
                helper.getView(R.id.imageViewAllClassifyHot).setVisibility(subBean.isHot() ? View.VISIBLE : View.GONE);
                break;
            case ITEM_TYPE:
                SongTypeEntity songTypeEntity= (SongTypeEntity) item;
                helper.setText(R.id.textViewAllClassifyItemType, songTypeEntity.getSongType());
                break;
        }

    }
}
